package servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import controller.EmpController;
import entity.T_account;

@WebServlet("/UpdatEmpServlet")
public class UpdataEmpServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    public UpdataEmpServlet() {
        super();
    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		EmpController controller=new EmpController();
		Integer id= Integer.parseInt(request.getParameter("id").toString());
		String name = request.getParameter("name");
		String number = request.getParameter("number");
		String money = request.getParameter("money");
		T_account emp=new  T_account(id,name,number,money);
		System.out.println(emp.toString());
		int updatAccount = controller.updataAccount(emp);
		if (updatAccount>0) {
			response.sendRedirect("EmpShowServlet");
		}
	}

}
